//
//  LSVideoScreenshotPreviewView.m
//  lightSpot
//
//  Created by lightSpot on 2021.
//  Copyright ©2021年 lightSpot. All rights reserved.
//

#import "LSVideoScreenshotPreviewView.h"

@implementation LSVideoScreenshotPreviewView

+ (id)instanceView {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    return [nibView objectAtIndex:0];
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setData:(id)data delegate:(id)delegate {

    if ([data isKindOfClass:[LSVideoScreenshotPreviewViewModel class]]) {
        LSVideoScreenshotPreviewViewModel *model = data;
        
        if (model.image.size.width > model.image.size.height) {
            //横
            _imageWidth.constant = kScreenWidth - 20;
            _imageHeight.constant = (kScreenWidth - 20)*model.image.size.height/model.image.size.width;
        } else {
            //竖
            _imageHeight.constant = self.frame.size.height - 20;
            _imageWidth.constant = (self.frame.size.height - 20)*model.image.size.width/model.image.size.height;
        }
        _myImageView.image = model.image;
    }
}

@end


@implementation LSVideoScreenshotPreviewViewModel

+ (LSVideoScreenshotPreviewViewModel *)ittemModelWithImage:(UIImage *)image {
    LSVideoScreenshotPreviewViewModel *model = [LSVideoScreenshotPreviewViewModel new];
    model.image = image;
    return model;
}

@end
